<template>
  <div>
    <div class='father'>
      <p style='text-align: left;line-height:0px'> <img :src="'./static/image/gold2.png'" alt=""></p>
      <p>当前：{{Math.floor(progress1*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiG' class='sunzi gold'>
          <p>当前{{progress1}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="display: none">
      <div class="top">
        <div class="weizhi">
          <div class="move" ref='move'>
            <img src="../../static/image/chongzi.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi"></div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
    <div class='father' style="top:290px;">
      <p style='text-align: left;line-height:0px;padding-top: 10px;'> <img :src="'./static/image/gold3.png'" alt=""></p>
      <p>当前：{{Math.floor(progress2*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiS' class='sunzi ying'>
          <p>当前{{progress2}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="top:290px;display:none;">
      <div class="top">
        <div class="weizhi">
          <div class="move" ref='move'>
            <img src="../../static/image/chongzi.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi"></div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
    <div class='father' style="top:390px">
      <p style='text-align: left;line-height:0px;padding-top: 20px'> <img :src="'./static/image/gold4.png'" alt=""></p>
      <p>当前：{{Math.floor(progress3*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiC' class='sunzi tong'>
          <p>当前{{progress3}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="top:390px;display:none;">
      <div class="top">
        <div class="weizhi">
          <div class="move" ref='move'>
            <img src="../../static/image/chongzi.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi"></div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import $ from "jquery";
import { setTimeout, setInterval, clearInterval } from "timers";
export default {
  data() {
    return {
      progress1: 0,
      progress2: 0,
      progress3: 0,
      status: parseInt(u.getStore("status")),
      img: ["nohuodong.png", "bdFont.png", "", "end.png"]
    };
  },
  created() {
    let time1 = setInterval(() => {
      if (u.flag) {
        clearInterval(time1);
        u.progress({cointype:localStorage.getItem('cointype')},data=>{
          console.log(data)
          if (data &&data[0].code == "200"){
            let arr=data[0].data;
            for(let i=0;i<arr.length;i++){
              if(arr[i].keyname=="gold" && arr[i].status==2){
                $(".father").eq(0).css("display","block");
                $(".borderStyle").eq(0).css("display","none");
                let progress1 = arr[i].count;
                this.$refs.sunziiG.style.width = progress1 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress1++;
                  if (this.progress1 >= progress1/100) {
                    this.progress1 = progress1/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="gold" && arr[i].status!=2){
                $(".father").eq(0).css("display","none");
                $(".borderStyle").eq(0).css("display","block");
              }else if(arr[i].keyname=="silver" && arr[i].status==2){
                $(".father").eq(1).css("display","block");
                $(".borderStyle").eq(1).css("display","none");
                let progress2 = arr[i].count;
                this.$refs.sunziiS.style.width = progress2 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress2++;
                  if (this.progress2 >= progress2/100) {
                    this.progress2 = progress2/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="silver" && arr[i].status!=2){
                $(".father").eq(1).css("display","none");
                $(".borderStyle").eq(1).css("display","block");
              }else if(arr[i].keyname=="copper" && arr[i].status==2){
                $(".father").eq(2).css("display","block");
                $(".borderStyle").eq(2).css("display","none");
                let progress3 = arr[i].count;
                this.$refs.sunziiC.style.width = progress3 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress3++;
                  if (this.progress3 >= progress3/100) {
                    this.progress3 = progress3/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="copper" && arr[i].status!=2){
                $(".father").eq(2).css("display","none");
                $(".borderStyle").eq(2).css("display","block");
              }
            }
          }
        })
      }
    }, 500);
  },
  methods: {
    bar() {}
  },

  mounted() {
    setTimeout(() => {
      this.bar();
    }, 1000);
  }
};
</script>

<style scoped lang='less'>
// .content {
//   height: 100vh;
//   width: 100vw;
//   // background: url(../../static/image/ginsengbg2.png) no-repeat center;
// }
.father {
  height: 100px;
  width: 520px;
  position: absolute;
  top: 190px;
  left: 0;
  padding:12px;
  box-sizing: border-box;
  .son {
    width: 100%;
    height: 60px;
    background: url(../../static/image/barbg.png) no-repeat center;
    .sunzi {
      position: relative;
      left: 14px;
      height: 100%;
      height: 27px;
      width: 0;
      transition: width 2s;
      line-height: 70px;
      // text-align: center;
      // text-shadow: -2px 1px 1px rgba(34, 113, 42, 0.75),
      //   2px -1px 1px rgba(34, 113, 42, 0.75);
      color: white;
      white-space: nowrap;
      box-sizing: border-box;
      border-radius: 12px;
      position: relative;
      top: 17px;
      p {
        width: 520px;
        box-sizing: border-box;
        padding-left: 200px;
        text-align: left;
        position: relative;
        top: -21px;
      }
    }
    .gold {
      background: url(../../static/image/goldProgress.png) no-repeat center;
      background-size: 160% 200%;
      p{
        text-shadow: 0 1px #914803, 1px 0 #914803, 1px 0 #914803,0 2px #914803;
      }
    }
    .ying {
      background: url(../../static/image/yingProgress.png) no-repeat center;
      background-size: 160% 200%;
      p{
        text-shadow:0 1px #545454, 1px 0 #545454, 0px 0 #545454, 0 2px #545454;
      }
    }
    .tong {
      background: url(../../static/image/tongProgress.png) no-repeat center;
      background-size: 160% 200%;
     p{
       text-shadow:0 1px #b43717, 1px 0 #b43717, 0px 0 #b43717, 0 2px #b43717;
     }
    }
    // .goldx{
    //   text-align: left;
    // }
  }

  p {
    font-size: 16px;
    color: white;
    padding-left: 10px;
    text-align: center;
    text-shadow:0 1px #d0801e, 1px 0 #d0801e, 0px 0 #d0801e, 0 2px #d0801e
  }
}
.borderStyle {
  width: 480px;
  height: 200px;
  padding-top: 69px;
  margin: auto;
  position: absolute;
  top: 190px;
  left: 0;
  .top {
    margin-bottom: 38px;
    .weizhi{
      height: 16px;
      background: url("../../static/image/bdBorder.png") no-repeat;
      position: relative;
      .move {
        position: absolute;
        height: 14px;
        background: url(../../static/image/move.png) no-repeat center;
        background-size: 100% 100%;
        width: 380px;
        height: 14px;
        text-align: right;
        transition: width 5s;
        img {
          position: relative;
          top: -300%;
        }
      }
      .qi {
        position: absolute;
        left: 470px;
        top: -33px;
      }
      .choangzi {
        position: absolute;
        top: -35px;
      }
    }
    p{
      margin-top: 10px;
      font-size: 16px;
      color: white;
      padding-left: 10px;
      text-shadow: -2px 1px 1px rgba(137, 64, 0, 0.75),
      2px -1px 1px rgba(137, 64, 0, 0.75);
      text-align: center;
    }
  }
  .fontStyle {
    text-align: center;
  }
}
</style>
